home *** CD-ROM | disk | FTP | other *** search
- package com.commerceone.util.collection;
-
- import com.commerceone.util.contract.Contract;
- import java.util.Enumeration;
-
- public class EnumerationPair implements Enumeration {
- private Enumeration begin;
- private final Enumeration end;
-
- public Object nextElement() {
- if (this.begin != null) {
- Object returnVal = this.begin.nextElement();
- if (!this.begin.hasMoreElements()) {
- this.begin = null;
- }
-
- return returnVal;
- } else {
- return this.end.nextElement();
- }
- }
-
- public EnumerationPair(Enumeration car, Enumeration cdr) {
- Contract.require(car != null && cdr != null);
- if (car.hasMoreElements()) {
- this.begin = car;
- } else {
- this.begin = null;
- }
-
- this.end = cdr;
- }
-
- public boolean hasMoreElements() {
- return this.begin != null ? this.begin.hasMoreElements() : this.end.hasMoreElements();
- }
- }
-